<template>
	<view class="content">
		<tabbar class="tabbar" :dataArray="dataArray" :checkedIndex="checkedIndex" @handleIndexChange="typeChange">
		</tabbar>
		<scroll-view scroll-y="true" class="list">
			<showLineItem v-for="(item,index) in actList" :id="item.id" :title="item.title" :img="item.img"
				@clickHandler="goTo"
				:style="index == actList.length-1?'margin-bottom: 40rpx;':''">
			</showLineItem>
			<!-- <showLineItem :id="1" title="历史厅——天下盐城" img="../../static/exhibition_img16@2x.png" @clickHandler="goTo">
			</showLineItem>
			<showLineItem :id="2" title="生态厅——水之韵" img="../../static/exhibition_img18@2x.png" @clickHandler="goTo">
			</showLineItem>
			<showLineItem :id="3" title="非遗民俗厅——海之魅" img="../../static/exhibition_img17@2x.png" @clickHandler="goTo">
			</showLineItem>
			<showLineItem :id="4" title="当代盐城厅——盐之翼" img="../../static/exhibition_img19@2x.png" @clickHandler="goTo"
				style="margin-bottom: 40rpx;"></showLineItem> -->
		</scroll-view>
		<!-- <scroll-view scroll-y="true" class="list" v-if="checkedIndex==1">
			<showLineItem :id="0" title="别有洞天" img="../../static/exhibition_img20@2x.png" @clickHandler="goTo">
			</showLineItem>
		</scroll-view>
		<scroll-view scroll-y="true" class="list" v-if="checkedIndex==2">
		</scroll-view> -->
	</view>
</template>

<script>
	import {
		doPostForm
	} from '../../js_sdk/request-helper.js'
	import tabbar from '../customer/tabbar.vue'
	import show from '../customer/show.vue'
	import showItem from '../customer/showItem.vue'
	import showItemOnline from '../customer/showItemOnline.vue'
	import showLineItem from '../customer/showLineItem.vue'
	export default {
		components: {
			tabbar,
			show,
			showItem,
			showItemOnline,
			showLineItem
		},
		data() {
			return {
				checkedIndex: 0,
				dataArray: [
					"基本陈列",
					"临时展览",
					"特别展览"
				],
				pages: 0,
				size: 5,
				actList: []
			}
		},
		onLoad(options) {
			if (options.index) {
				this.pages = 0
				this.checkedIndex = options.index
				this.getList()
			}else{
				this.pages = 0
				this.checkedIndex = 0
				this.getList()
			}
		},
		methods: {
			getList() {
				let typeCode, typeName
				if (this.checkedIndex == 0) {
					typeCode = 1
					typeName = '基本陈列'
				} else if (this.checkedIndex == 1) {
					typeCode = 1
					typeName = '临时展览'
				} else if (this.checkedIndex == 2) {
					typeCode = 2
				}
				doPostForm('/blade-museum/act/list', {
					pages: this.pages,
					size: this.size,
					typeCode: typeCode,
					typeName: typeName,
					auditState: true,
					museumId: uni.getStorageSync('museumId')
				}, (res) => {
					let list = []
					for (let item of res.records) {
						list.push(item)
					}
					this.actList = list
				}, (err) => {})
			},
			typeChange(index) {
				this.pages = 0
				this.checkedIndex = index
				this.getList()
			},
			goTo(id) {
				uni.navigateTo({
					url: './showInfo?id=' + id
				})
			}
		}
	}
</script>

<style>
	.content {
		position: fixed;
		width: 100%;
		height: calc(100% - 88rpx);
		/* flex-direction: column;
		align-items: center;
		justify-content: flex-start; */
	}

	.tabbar {
		width: 100%;
	}

	.list {
		background: #eee;
		position: fixed;
		height: calc(100% - 168rpx);
		width: 100%;
	}
</style>
